wayland: Trivial refactor
authorMatthias Clasen <mclasen@redhat.com>
Mon, 31 Aug 2015 14:54:07 +0000 (10:54 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 31 Aug 2015 15:07:00 +0000 (11:07 -0400)
Break out a stop_key_repeat function instead of open-coding this
in several places.

gdk/wayland/gdkdevice-wayland.c

index 9b190f2277eafb2248a77c953e29b059db3065a4..3a9c334e33703c2e16cd8c5baff1e593f70c45af 100644 (file)
@@ -1333,6 +1333,16 @@ get_key_repeat (GdkWaylandDeviceData *device,
   return repeat;
 }
 
+static void
+stop_key_repeat (GdkWaylandDeviceData *device)
+{
+  if (device->repeat_timer)
+    {
+      g_source_remove (device->repeat_timer);
+      device->repeat_timer = 0;
+    }
+}
+
 static gboolean
 deliver_key_event (GdkWaylandDeviceData *device,
                    uint32_t              time_,
@@ -1387,11 +1397,7 @@ deliver_key_event (GdkWaylandDeviceData *device,
 
   if (state == 0)
     {
-      if (device->repeat_timer)
-        {
-          g_source_remove (device->repeat_timer);
-          device->repeat_timer = 0;
-        }
+      stop_key_repeat (device);
       return FALSE;
     }
   else
@@ -1399,11 +1405,7 @@ deliver_key_event (GdkWaylandDeviceData *device,
       switch (device->repeat_count)
         {
         case 1:
-          if (device->repeat_timer)
-            {
-              g_source_remove (device->repeat_timer);
-              device->repeat_timer = 0;
-            }
+          stop_key_repeat (device);
           device->repeat_timer =
             gdk_threads_add_timeout (delay, keyboard_repeat, device);
           g_source_set_name_by_id (device->repeat_timer, "[gtk+] keyboard_repeat");